﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test.DAL
{
    public interface IFacadeBase
    {
        void Initialize();
        void Dispose();
    }

    //public abstract class FacadeBase : IDisposable
    //{
    //    public FacadeBase()
    //    {

    //    }

    //    public abstract void Initialize();

    //    public abstract void Dispose();
    //}

    public abstract class FacadeBase<T> : IFacadeBase, IDisposable where T : class, new()
    {
        public FacadeBase()
        {
        }

        public static T Create()
        {
            T retValue = new T();

            ((IFacadeBase)retValue).Initialize();

            return retValue;
        }

        public abstract void Initialize();

        public abstract void Dispose();

        public Repository<E, Ekey> GetRepository<E, Ekey>(DbContext context) 
            where E : class
            //where Context : DbContext, new()
        {
            return new Repository<E, Ekey>(context);
        }
    }
}
